package fun.asgc.boot.netty.db.mapper;

import fun.asgc.boot.netty.annotation.Component;
import fun.asgc.boot.netty.aop.Intercept;
import fun.asgc.boot.netty.db.annotation.Insert;
import fun.asgc.boot.netty.db.annotation.ResultType;
import fun.asgc.boot.netty.db.annotation.Select;

import java.util.List;

/**
 *
 * @author: aoshiguchen
 * @date: 2022/6/28
 */
@Intercept(exceptionHandler = TestExceptionHandler.class)
@Component
public interface UserMapper extends SqlMapper {

	@Select("select * from user where id = ?")
	User findOneById(Long id);

	@ResultType(User.class)
	@Select("select * from user")
	List<User> findAll();

	@Select("select count(1) from user")
	int count();

	@Insert("insert into user(`id`,`name`,`age`,`email`,`sex`,`create_time`) values(:id,:name,:age,:email,:sex,:createTime)")
	int add(User user) throws Exception;
}
